package tech.edwardvan.springbootdemo.factorybean;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.stereotype.Component;
import tech.edwardvan.springbootdemo.entity.Demo;

/**
 * 工厂类
 *
 * @author EdwardVan
 */
@Component
public class DemoFactoryBean implements FactoryBean<Demo> {
    @Override
    public Demo getObject() throws Exception {
        return new Demo();
    }

    @Override
    public Class<?> getObjectType() {
        return Demo.class;
    }

    /**
     * 判断是否是单实例
     * 返回true则是单例的 在IOC容器中保存一份
     * 返回false则是多例的 每次获取都调用getObject()方法返回bean
     *
     * @return
     */
    @Override
    public boolean isSingleton() {
        return true;
    }
}
